package 泛型.反省擦除;

public class GenericArray2<T> {
	private Object[] array;

	public GenericArray2(int size) {
		array = new Object[size];
	}

	public void put(int index, T item) {
		array[index] = item;
	}

	public T get(int index) {
		return (T) array[index];
	}

	public T[] rep() {
		return (T[]) array;
	}

	public static void main(String[] args) {
		GenericArray2<Integer> integerGenericArray2 = new GenericArray2<Integer>(3);
		for (int i = 0; i < 3; i++) {
			integerGenericArray2.put(i, i);
		}
		for (int i = 0; i < 3; i++) {
			System.out.println(integerGenericArray2.get(i) + "");
			System.out.println();
		}
		// 依然是error，因为object[] 无法转换为 int[]
		Integer[] integers = integerGenericArray2.rep();
		System.out.println(integerGenericArray2);
	}
}
